using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace MyUnityUtils
{
    public class BaseUtils
    {
        /// <summary>
        /// 清空子物体
        /// </summary>
        public static void clear_children(GameObject obj)
        {
            var trans = obj.transform;
            // 获取当前对象的所有子物体数量
            int childCount = trans.childCount;

            // 遍历并销毁所有子物体
            for (int i = childCount - 1; i >= 0; i--)
            {
                // 获取子物体
                Transform child = trans.GetChild(i);

                // 销毁子物体
                Object.Destroy(child.gameObject);
            }
        }
    }
}
